package com.itheima.day09.Zuoye.ZuoYe5;

import java.util.*;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        Scanner r=new Scanner(System.in);
        System.out.println("请输入第一个学生姓名");
        String name1=r.next();
        System.out.println("请输入第二个学生姓名");
        String name2=r.next();
        System.out.println("请输入第三个学生姓名");
        String name3=r.next();
        System.out.println("请输入第一个学生年龄");
        int age1=r.nextInt();
        System.out.println("请输入第二个学生年龄");
        int age2=r.nextInt();
        System.out.println("请输入第三个学生年龄");
        int age3=r.nextInt();
        List<Stu> list= new ArrayList<>();
        list.add(new Stu(name1, age1));
        list.add(new Stu(name2, age2));
        list.add(new Stu(name3, age3));
        System.out.println("请输入第一个学生居住地信息");
        String address1=r.next();
        System.out.println("请输入第二个学生居住地信息");
        String address2=r.next();
        System.out.println("请输入第三个学生居住地信息");
        String address3=r.next();
        List<String> list1= new ArrayList<>();
        list1.add(address1);
        list1.add(address2);
        list1.add(address3);
        Map<Stu,String> map= new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            map.put(list.get(i),list1.get(i));
        }
        Stream<Map.Entry<Stu, String>> stream = map.entrySet().stream();
        List <Map.Entry<Stu, String>> list2 =stream.sorted((o1, o2) -> o2.getValue().compareTo(o1.getValue())).toList();
        list2.forEach(System.out::println);

    }
}
